package com.csci;

import java.awt.GridLayout;
import javax.swing.JPanel;
import java.util.Random;

public class SudokuBoxPanel {
	int dimension;
	JPanel boxPanel;
	SudokuGridElement[][] sudokuGridElement;
	int[][] gridElement;
	Random rand;
	
	public SudokuBoxPanel(int dimension, int[][] gridElement){
		this.dimension = dimension;
		boxPanel = new JPanel(new GridLayout(dimension, dimension));
		sudokuGridElement =  new SudokuGridElement[dimension][dimension];
		if(gridElement == null){
			rand = new Random();
			initializeBoxPanelRandom();
		}
		else{
			this.gridElement = gridElement;
			initializeBoxPanel();
		}
	}
	
	
	
	
	
	public void initializeBoxPanelRandom() {
		for(int row = 0; row < dimension; row++){
			for(int col = 0; col < dimension; col++){
				boxPanel.add(new SudokuGridElement(rand.nextInt(10)));
			}
		}
	}
	
	public void initializeBoxPanel() {
		for(int row = 0; row < dimension; row++){
			for(int col = 0; col < dimension; col++){
				boxPanel.add(new SudokuGridElement(gridElement[row][col]));
			}
		}
	}
	
}
